let s = 'AbcDefGh';
function changeCase(s) {
  let result = '';
  if (!s.length) return;
  for (let i of s) {
    // result += /[a-z]/.test(i)? i.toUpperCase() : i.toLowerCase()
    if (/[A-Z]/.test(i)){
      result += i.toLowerCase()
    } else {
      result += i.toUpperCase()
    }
  }
  return result
}

function changeCase(s) {
  if (typeof s !== 'string' || !s.length) return;  
  return s.replace(/[a-zA-Z]/g, function(a) {
    return /[a-z]/.test(a)? a.toUpperCase() : a.toLowerCase()
  })
}

function changeCase3(s) {
  if (typeof s !== 'string' || !s.length) return 666;
  // return s.split('').map(item => {
    return [...s].map(item => {
    return /[a-z]/.test(item)? item.toUpperCase() : item.toLowerCase()
  }).join('')
}

console.log(changeCase3(s))